package cn.iocoder.yudao.module.train.controller.wechat.vip;

import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.train.dal.dataobject.viplevel.VipLevelDO;
import cn.iocoder.yudao.module.train.service.viplevel.VipLevelService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

import static cn.iocoder.yudao.framework.common.pojo.CommonResult.error;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;

@RestController
@RequestMapping("/wechat-api/vip")
public class WechatVipController {

    @Resource
    private VipLevelService vipLevelService;

    @GetMapping("/listVipLevel")
    public CommonResult<List<VipLevelDO>> listVipLevel() {
        try {
            return success(vipLevelService.getAllVipLevel());
        } catch (Exception e) {
            return error(500, e.getMessage());
        }
    }

    @GetMapping("/getVipLevelInfo")
    public CommonResult<VipLevelDO> getVipLevelInfo(Integer vipLevelId) {
        try {
            return success(vipLevelService.getVipLevel(vipLevelId));
        } catch (Exception e) {
            return error(500, e.getMessage());
        }
    }
}
